import { FormProps, FormSchema } from '@/components/Table';
import { BasicColumn } from '@/components/Table/src/types/table';

export function getBasicColumns(): BasicColumn[] {
  return [
    {
      title: 'id',
      dataIndex: 'id',
      defaultHidden: true,
    },
    {
      title: '条码号',
      dataIndex: 'barcode',
      fixed: 'left',
      width: 150,
    },
    {
      title: '登记时间',
      dataIndex: 'createTime',
      width: 180,
    },
    {
      title: '姓名',
      dataIndex: 'name',
      width: 150,
    },
    {
      title: '性别',
      dataIndex: 'gender',
      width: 100,
    },
    {
      title: '年龄',
      dataIndex: 'age',
      width: 100,
    },
    {
      title: '身份证号',
      dataIndex: 'idCard',
    },
    {
      title: '套餐',
      dataIndex: 'tjCheck',
      width: 150,
      customRender: ({ record }) => {
        if (record.tjCheck === '1') {
          return '老年人体检';
        }
      },
    },
    {
      title: '登记医生',
      dataIndex: 'buserName',
      width: 150,
    },
    {
      title: '现居地址',
      dataIndex: 'address',
    },
    {
      title: '联系电话',
      dataIndex: 'phone',
    },
  ];
}
export const getAdvanceSchema = (): FormSchema[] => {
  const arr: any = [
    {
      field: `orgncode`,
      label: `机构`,
      component: 'Input',
      colProps: {
        span: 6,
      },
    },
    {
      field: `barcode`,
      label: `条码编号`,
      component: 'Input',
      colProps: {
        span: 6,
      },
    },
    {
      field: `name`,
      label: `姓名`,
      component: 'Input',
      colProps: {
        span: 6,
      },
    },
    {
      field: `idCard`,
      label: `身份证号`,
      component: 'Input',
      colProps: {
        span: 6,
      },
    },
    {
      field: '[createTimeFrom, createTimeTo]',
      label: '登记日期',
      component: 'RangePicker',
      colProps: {
        span: 6,
      },
      componentProps: {
        format: 'YYYY-MM-DD',
        placeholder: ['开始日期', '结束日期'],
      },
    },
    {
      field: `isDeleted`,
      component: 'RadioGroup',
      label: '是否删除',
      colProps: {
        span: 6,
      },
      defaultValue: '0',
      componentProps: {
        options: [
          {
            label: '已删除',
            value: '1',
          },
          {
            label: '未删除',
            value: '0',
          },
        ],
      },
    },
  ];
  return arr;
};
export function getFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 100,
    wrapperCol: {
      span: 24,
    },
    colon: true,
    showAdvancedButton: true,
    schemas: [...getAdvanceSchema()],
    autoSubmitOnEnter: true,
  };
}
